package com.icinfo.wanandroid.base.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.test.espresso.IdlingResource;

import me.yokeyword.fragmentation.SupportActivity;

import com.icinfo.wanandroid.component.ActivityCollector;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Author: 胡高建
 * Comment: //TODO
 * Date: 2019-07-24 10:16
 */
public abstract class AbstractSimpleActivity extends SupportActivity {
    private Unbinder unbinder;
    protected AbstractSimpleActivity mActivity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        unbinder = ButterKnife.bind(this);
        mActivity = this;
        ActivityCollector.getInstance().addActivity(this);
        onViewCreated();
        initToolbar();
        initEventAndData();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityCollector.getInstance().remoteActivity(this);
        if (unbinder != null && unbinder != Unbinder.EMPTY) {
            unbinder.unbind();
            unbinder = null;
        }
    }

    //@VisibleForTesting
//public IdlingResource getCountingIdlingResource(){
//        return EspressoId
//}
    protected abstract void initEventAndData();

    protected abstract void initToolbar();

    protected abstract void onViewCreated();

    protected abstract int getLayoutId();
}
